<template>
	<view class="page" :style="{ 'min-height': h + 'px', 'padding-top': (mt) + 'px' }">
		<!-- <customNavBar1 :title="title"></customNavBar1> -->
		<c-nav-bar :title="title"></c-nav-bar>


		<view class="user" v-if="searchList">
			<view class="user-img">
				<image style="border-radius: 50%;" :src="searchList.headUrl" mode="aspectFill">
				</image>
			</view>
			<view class="user-right">
				<view class="user-name">
					{{ searchList.realNameCopy }}
				</view>
				<view class="user-time">
					{{ searchList.createDate }}
				</view>
			</view>
		</view>

		<view class="content" v-if="searchList">
			<view class="one">
				想找：{{ searchList.positionName }}
			</view>
			<view class="two">
				期待薪资：{{ searchList.money }}
			</view>
		</view>

		<view class="text-text" v-if="searchList">
			<view class="one">
				简历详情
			</view>
			<view class="text-one">
				姓名：{{ searchList.workNameCopy }}
			</view>
			<view class="text-one" style="margin-bottom: 40rpx;">
				联系方式：{{ searchList.phoneCopy }}
			</view>
			<view class="text-one" style="margin-bottom: 80rpx;">
				学历：{{ searchList.education }}
			</view>
			<view class="text-one" style="margin-bottom: 80rpx;">
				工作经验：{{ searchList.experience }}
			</view>
			<view class="text-one" style="margin-bottom: 80rpx;">
				自我介绍：{{ searchList.advantage }}
			</view>


		</view>

		<view class="bottom-input" v-if="type == 0">
			<view class="bottom-left" @click="Hired(searchList)">
				确认录用
			</view>
			<view class="bottom-right" @click="phone(searchList.phone)">
				电话联系
			</view>
		</view>


		<!-- 授权手机登录 -->
		<GetPhoneNumber ref="phoneNumber" @loginSuccess="loginSuccess"></GetPhoneNumber>
	</view>


</template>

<script>
	import GetPhoneNumber from '@/compoments/Getphonenumber/index.vue'
	import inputBox from '@/compoments/inputBox/inputBox.vue'
	export default {
		components: {
			GetPhoneNumber,
			inputBox,
		},
		data() {
			return {
				title: '求职详情', //0
				h: uni.getSystemInfoSync().windowHeight,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				searchList: {},
				substrings: [],
				type: null,
				fromData: {
					education: "",
					// id: 0,
					jobId: 0,
					money: 0,
					name: "",
					phone: "",
					workName: "",
					workingHours: "",
					userId: '',
					address: '',
					realName: '',
				}
			};
		},

		onLoad(option) {
			console.log(option);
			let obj = JSON.parse(option.obj)
			console.log(obj, '-----');
			this.id = obj.id
			this.type = obj.type
			this.commjobhunt(obj.id)
			// this.$login().then(res => {
			// 	if (res !== 0) {
			// 		this.$refs['phoneNumber'].show = true;
			// 	}
			// })


		},
		methods: {

			// 电话联系
			phone(phone) {
				console.log('电话联系');
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});

			},
			//确定录用
			Hired(item) {
				this.fromData.education = item.education
				this.fromData.jobId = item.id
				this.fromData.userId = item.creator
				this.fromData.money = item.money
				this.fromData.phone = item.phone
				this.fromData.name = item.workName
				this.fromData.workName = item.positionName
				this.fromData.workingHours = item.experience
				this.fromData.address = item.address
				this.fromData.realName = item.realName

				let newData = JSON.parse(JSON.stringify(this.fromData));
				newData.name = this.$aesTm.encrypt(newData.name);
				newData.phone = this.$aesTm.encrypt(newData.phone);
				newData.realName = this.$aesTm.encrypt(newData.realName);

				this.$api.post('/api/commrecruit/employment', newData).then(res => {
					if (res.data.code == 0) {
						this.$showToast('录用成功');
					}

				})
			},
			loginSuccess() {
				this.commrecruit(this.id)
			},

			// 获取详情数据
			commjobhunt(id) {
				this.$api.get(`/api/commjobhunt/getOne?id=${id}`)
					.then(res => {

						this.searchList = res.data.data;
						this.searchList.realNameCopy = this.$aesTm.tuomin(this.searchList.realName, 1);
						this.searchList.workNameCopy = this.$aesTm.tuomin(this.searchList.workName, 1);
						this.searchList.phoneCopy = this.$aesTm.tuomin(this.searchList.phone, 2);
						// 根据逗号(,)分割字符串
						this.substrings = this.searchList.content.split('\n');


					})
			},


		}
	}
</script>
<style lang="less">
	.u-moreList {
		width: 60% !important;
	}

	.swiper {
		box-sizing: border-box;
		width: 100vw;
		height: 450rpx !important;
		backdrop-filter: blur(300px);
		background: rgba(251, 251, 251, .1);

	}

	.bottom-input {
		position: fixed;
		background-color: #FFFFFF;
		bottom: 0;
		height: 136rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		text-align: center;
		display: flex;
		justify-content: space-between;
		width: 100%;

		:nth-child(1) {
			height: 88rpx;
			line-height: 88rpx;
			// width: 690rpx;
			width: 320rpx;
			border-radius: 50rpx;
			font-size: 32rpx;
			font-weight: Regular;
			color: #007A69;
			text-align: center;
			margin: 20rpx auto;
			border: 1rpx solid #007A69;
		}

		:nth-child(2) {
			width: 320rpx;
			height: 88rpx;
			line-height: 88rpx;
			// width: 690rpx;
			background-color: #007A69;
			border-radius: 50rpx;
			font-size: 32rpx;
			font-weight: Regular;
			color: #FFFFFF;
			text-align: center;
			margin: 20rpx auto;
		}
	}

	.u-badge {
		padding: 0 !important;
		background-color: #FFFFFF !important;
		margin-left: -14rpx;
		color: #666666 !important;
		margin-top: 5rpx;
	}

	.u-input__content__field-wrapper__field {
		font-size: 24rpx;
		margin-left: 30rpx;
	}

	.indicator {
		// @include flex(row);
		display: flex;
		justify-content: center;

		&__dot {
			height: 6px;
			width: 6px;
			border-radius: 100px;
			background-color: rgba(255, 255, 255, 0.35);
			margin: 0 5px;
			transition: background-color 0.3s;

			&--active {
				background-color: #ffffff;
			}
		}
	}

	.u-modal__content__text {
		text-align: center !important;
	}
</style>

<style lang="scss">
	.page {
		margin: 0;
		box-sizing: border-box;
		padding: 0;
		// background-color: aqua;
		// height: 100vh;
	}

	.user {
		display: flex;
		padding: 31rpx 24rpx;

		.user-img {
			margin-right: 31rpx;
			width: 36px;
			height: 36px;

			image {
				height: 36px;
				width: 36px;
			}
		}

		.user-right {
			.user-name {
				font-size: 30rpx;
				color: #111111;
			}

			.user-time {
				font-size: 24rpx;
				color: #999999;
			}
		}


	}

	.content {
		padding: 26rpx;

		.one {
			font-size: 32rpx;
			color: #333333;
			font-weight: Bold
		}

		.two {
			margin-top: 24rpx;
			font-size: 32rpx;
			color: #FF4141;
			font-weight: Bold
		}
	}

	.text-text {
		padding: 26rpx 26rpx 200rpx;
		// border-bottom: 1rpx solid #f0f2f5;

		.one {
			font-size: 32rpx;
			color: #333333;
			font-weight: Bold
		}

		.text-one {
			font-size: 30rpx;
			color: #333;
			font-weight: Regular;
			margin: 12rpx 0;
		}

		.text-two {
			font-size: 30rpx;
			color: #666666;
			line-height: 48rpx;
			font-weight: Regular;

		}
	}
</style>